package com.atguigu.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/servlet5")
public class Servlet5 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置响应行相关的api
        resp.setStatus(200);
        resp.setHeader("aaa","bbb");

        resp.setContentType("text/html");
        //设置响应体内容 api   获得一个向响应体输入文本字符输出流
        String info="hello servlet";
        resp.getWriter().write(info);
        resp.setContentLength(info.getBytes().length);
    }

}
